﻿using System.Collections.Generic;
using System.Data;
using MaLu.Data;

namespace MaLu.BusiLogic
{
   public class BLFarm
    {
       public static DataSet GetAllowanceByYearAndVillage(IDbProvider provider, int year, int villageid)
       {
           List<IDataParameter> paraList = new List<IDataParameter>();
           paraList.Add(SqlHelper.Instance.CreateParameter("@Year", DataType.Int32,8, year));
           paraList.Add(SqlHelper.Instance.CreateParameter("@VilliageID", DataType.Int32, 8, villageid));
           DataSet ds = SqlHelper.Instance.ExecuteProcedure(provider, "Proc_GetMoneyByVilliageID", paraList.ToArray());
           return ds;
       }
       public static DataSet SumHuafei(IDbProvider provider, int year, int villageid)
       {
           List<IDataParameter> paraList = new List<IDataParameter>();
           paraList.Add(SqlHelper.Instance.CreateParameter("@Year", DataType.Int32, 8, year));
           paraList.Add(SqlHelper.Instance.CreateParameter("@VillageID", DataType.Int32, 8, villageid));
           DataSet ds = SqlHelper.Instance.ExecuteProcedure(provider, "Proc_FSumHuaFei", paraList.ToArray());
           return ds;
       }
       public static DataSet SumCold(IDbProvider provider, int year, int villageid)
       {
           List<IDataParameter> paraList = new List<IDataParameter>();
           paraList.Add(SqlHelper.Instance.CreateParameter("@Year", DataType.Int32, 8, year));
           paraList.Add(SqlHelper.Instance.CreateParameter("@VillageID", DataType.Int32, 8, villageid));
           DataSet ds = SqlHelper.Instance.ExecuteProcedure(provider, "Proc_FSumCold", paraList.ToArray());
           return ds;
       }


       public static DataSet SumBooth(IDbProvider provider, int year, int villageid)
       {
           List<IDataParameter> paraList = new List<IDataParameter>();
           paraList.Add(SqlHelper.Instance.CreateParameter("@Year", DataType.Int32, 8, year));
           paraList.Add(SqlHelper.Instance.CreateParameter("@VillageID", DataType.Int32, 8, villageid));
           DataSet ds = SqlHelper.Instance.ExecuteProcedure(provider, "Proc_FSumBooth", paraList.ToArray());
           return ds;
       }
       public static DataSet SumMembrane(IDbProvider provider, int year, int villageid)
       {
           List<IDataParameter> paraList = new List<IDataParameter>();
           paraList.Add(SqlHelper.Instance.CreateParameter("@Year", DataType.Int32, 8, year));
           paraList.Add(SqlHelper.Instance.CreateParameter("@VillageID", DataType.Int32, 8, villageid));
           DataSet ds = SqlHelper.Instance.ExecuteProcedure(provider, "Proc_FSumMembrane", paraList.ToArray());
           return ds;
       }
       public static DataSet SumPackage(IDbProvider provider, int year, int villageid)
       {
           List<IDataParameter> paraList = new List<IDataParameter>();
           paraList.Add(SqlHelper.Instance.CreateParameter("@Year", DataType.Int32, 8, year));
           paraList.Add(SqlHelper.Instance.CreateParameter("@VillageID", DataType.Int32, 8, villageid));
           DataSet ds = SqlHelper.Instance.ExecuteProcedure(provider, "Proc_FSumPackage", paraList.ToArray());
           return ds;
       }
       public static DataSet SumGreen(IDbProvider provider, int year, int villageid)
       {
           List<IDataParameter> paraList = new List<IDataParameter>();
           paraList.Add(SqlHelper.Instance.CreateParameter("@Year", DataType.Int32, 8, year));
           paraList.Add(SqlHelper.Instance.CreateParameter("@VillageID", DataType.Int32, 8, villageid));
           DataSet ds = SqlHelper.Instance.ExecuteProcedure(provider, "Proc_FSumGreen", paraList.ToArray());
           return ds;
       }


       public static DataTable GetMoneyDetailByVillageIDAndYear(IDbProvider provider, int year, int villageid)
       {

           List<IDataParameter> paraList = new List<IDataParameter>();
           paraList.Add(SqlHelper.Instance.CreateParameter("@Year", DataType.Int32, 8, year));
           paraList.Add(SqlHelper.Instance.CreateParameter("@VillageID", DataType.Int32, 8, villageid));
           DataSet ds = SqlHelper.Instance.ExecuteProcedure(provider, "Proc_GetMoneyDetailByVillageIDAndYear", paraList.ToArray());
           return ds.Tables[0];
       }

       public static string GetName(string type)
       {
           type = type.ToLower();
           string name=string.Empty;
           if (type == "fbooth")
               name = "摊位" ;
           if (type == "fhuafei")
               name = "有机肥";
           if (type == "fcold")
               name = "冷库";
           if (type == "fgreen")
               name = "大棚";
           if (type == "fmembrane")
               name = "银灰膜";
           if (type == "fpackage")
               name = "包装箱";
           return name;
       
       }
       public static DataTable GetFType()
       {
           DataTable dt = new DataTable();
           dt.Columns.Add("value");
           dt.Columns.Add("text");

           string[] values = new string[] { "fbooth","fhuafei","fcold","fgreen","fmembrane","fpackage"};
           string[] texts = new string[] { "摊位", "有机肥", "冷库", "大棚", "银灰膜", "包装箱" };
           int length = values.Length;
           for (int i = 0; i < length; i++)
           {
               DataRow dr = dt.NewRow();
               dr["value"] = values[i];
               dr["text"] = texts[i];
               dt.Rows.Add(dr);
           }

           return dt;
       
       }

       public static DataTable GetFType(IDbProvider provider)
       {
           return SqlHelper.Instance.ExecuteDataTable(provider, "select * from DicVillages");
       }
    } 
}
